﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Sql;
using System.Data.SqlClient;
using System.Data;


namespace DAL
{
    public class KetNoi
    {
        SqlConnection con = new SqlConnection();
        public void KetNoiCoSoDuLieu()
        {
           con.ConnectionString = "Data Source=.;Initial Catalog=QuanLyCuaHangQuanAo;Integrated Security=True";
           try
           {
               con.Open();
           }
           catch (SqlException ex)
           {

           }
         }
        public DataTable ExecuteQuery(SqlCommand cmd)
        {
            cmd.Connection = con;
            SqlDataAdapter da = new SqlDataAdapter(cmd);
            DataTable dt=new DataTable();
            KetNoiCoSoDuLieu();
            da.Fill(dt);
            return dt;
            con.Close();
        }
        public bool ExcuteNonquery(string query)
        {
            SqlCommand cmd = new SqlCommand(query,con);
            cmd.CommandText = query;
            if (cmd.ExecuteNonQuery()>0)
                return true;
            else
                return false;
        }
    }
}
